package it.codelair.bakekaservice;

import it.codelair.bakekaservice.Utilities.NetworkCalls;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class PrincipaleActivity extends Activity implements OnClickListener{

	private View view;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_principale);
		final ImageButton foodButton= (ImageButton) findViewById(R.id.imageButton1);
		foodButton.setOnClickListener(this);
		final ImageButton gardeningButton= (ImageButton) findViewById(R.id.imageButton2);
		gardeningButton.setOnClickListener(this);
		final ImageButton serviceButton= (ImageButton) findViewById(R.id.imageButton3);
		serviceButton.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.principale, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		this.setView(v);
		String category = "";
		switch ( v.getId() ) {
			case R.id.imageButton1:
				category="food";
				break;
			case R.id.imageButton2:
				category="gardening";
				break;
			case R.id.imageButton3:
				category="service";
				break;
		}
		Intent home = new Intent(getApplicationContext(), ServicesActivity.class);
		Bundle b = new Bundle();
		b.putString("category", category); 
		home.putExtras(b);
        startActivity(home);
	}

	public View getView() {
		return view;
	}

	public void setView(View view) {
		this.view = view;
	}

}
